Index
Table of Content
A plugin is a chunk of code that is compiled as a shared library and inserted into the simulation. The plugin has direct access to all the functionality of Gazebo through the standard C++ classes.
There are currently 6 types of plugins
- World
- Model
- Sensor
- System
- Visual
- GUI
Each plugin type is managed by a different component of Gazebo
install gazebo-dev for plugin build
# ubuntu 22.04
sudo apt install libgazebo-dev
# gazebo version
# sudo apt install libgazebo<XX>-dev
Reference#
Minimal DEMO#
Gazebo world plugin
├── bin
├── build
├── CMakeLists.txt
├── src
│ └── world_plugin.cc
└── worlds
└── demo_world_plugin.world
<?xml version="1.0"?>
<sdf version="1.4">
<world name="default">
<plugin name="hello_world" filename="libhello_world.so"/>
<include>
<uri>model://ground_plane</uri>
</include>
<include>
<uri>model://sun</uri>
</include>
</world>
</sdf>
#include <gazebo/gazebo.hh>
#include <gazebo/common/common.hh>
namespace gazebo
{
class WorldPluginTutorial : public WorldPlugin
{
public:
WorldPluginTutorial() : WorldPlugin()
{
gzmsg << "gazebo message \n";
gzdbg << "gazebo debug \n";
gzwarn << "gazebo warning \n";
gzerr << "gazebo error \n";
}
public:
void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)
{
}
};
GZ_REGISTER_WORLD_PLUGIN(WorldPluginTutorial)
}
```c title=”CMakeLists.txt cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(GAZEBO_PLUGIN_DEMO)
find_package(gazebo REQUIRED) include_directories(\({GAZEBO_INCLUDE_DIRS}) link_directories(\)) list(APPEND CMAKE_CXX_FLAGS “${GAZEBO_CXX_FLAGS}”)
set(CMAKE_INSTALL_PREFIX “${PROJECT_SOURCE_DIR}”)
add_library(hello_world SHARED src/world_plugin.cc) target_link_libraries(hello_world ${GAZEBO_LIBRARIES}) install(TARGETS hello_world DESTINATION bin)
---
### Usage
!!! tip "GAZEBO_PLUGIN_PATH"
Set `GAZEBO_PLUGIN_PATH` environment variable
